package view;

import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JPanel;
import model.Heightmap;

public class DrawHeightmap extends JPanel{
    
    int [][] mapa;
    
    @Override
    public void paintComponent(Graphics g) {
        this.setDoubleBuffered(true);
        super.paintComponent(g);
        
        for (int i = 0; i < mapa.length; i++) {
            for (int j = 0; j < mapa[0].length; j++) {
                g.setColor(new Color(getColor(mapa[i][j]), getColor(mapa[i][j]), getColor(mapa[i][j])));
                g.drawLine(i, j, i, j);
            }
        }
    }

    public void setParametros(Heightmap h) {
        this.mapa = h.getMapaMatriz();
    }
    
    private int getColor(int c) {
        return (c & 0xFF);
    }
}
